package main;

import entity.Student;
import org.junit.Test;
import service.StudentService;
import service.impl.StudentServiceImpl;
import com.qf.utils.DruidUtil;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/*
杨威
2021/9/7
19:41
*/
public class TestStudentService {
    StudentService studentService=new StudentServiceImpl();
    @Test
    public void TestInsert(){
        try {
            Date parse=new SimpleDateFormat("yyyy-MM-dd").parse("1995-03-6");
            Student student = new Student(0,"李四", "男", "1224892648915",parse,"zhangsanvip@qq.com","上海市宝坻区" , 1);
            studentService.addStudentIfo(student);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    @Test
    public void TestDelete(){
        studentService.deleteByStuId(20);
    }
    @Test
    public void TestUpdate(){
        try {
            Date parse = new SimpleDateFormat("yyyy-mm-dd").parse("1998-2-6");
            Student student=new Student(21,"wangWu","男","1651651684",parse,"163@123.com","shenyang",2);
            int i = studentService.updateByStuId(student);
            System.out.println("i = " + i);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    @Test
    public void TestSelectOne(){
        Student student = studentService.selectByStuId(1);
        System.out.println("student = " + student);
    }
    @Test
    public void TestSelectAll(){
        List<Student> students = studentService.showAllStudent();
        students.forEach(System.out::println);
    }
    @Test
    public void TestConnection(){
        System.out.println(DruidUtil.getConnection());
        System.out.println(DruidUtil.getConnection());

    }
}
